package com.example.datachange.test;

import com.example.datachange.utils.StringUtils;
import com.stars.datachange.model.code.BaseCode;

/**
 * 设施配置字典模型
 * @author Hao.
 * @version 1.0
 * @date 2022/4/7 9:27
 */
public enum FacilityConfigCode implements BaseCode {

    /**
     * 设施类型
     */
    FACILITY_TYPE_1("facilityType", "1", "电子警察"),
    FACILITY_TYPE_2("facilityType", "2", "机柜"),

    /**
     * 是否存在网关
     */
    GATEWAY_FLAG_0("gatewayFlag", "0", "是"),
    GATEWAY_FLAG_1("gatewayFlag", "1", "否"),

    /**
     * 人工巡检
     */
    MANUAL_INSPECT_0("manualInspect", "0", "是"),
    MANUAL_INSPECT_1("manualInspect", "1", "否"),

            ;
    private final String t;
    private final String k;
    private final String v;

    FacilityConfigCode(String t, String k, String v) {
        this.t = t;
        this.k = k;
        this.v = v;
    }

    public String getT() {
        return t;
    }

    public String getK() {
        return k;
    }

    public String getV() {
        return v;
    }

    @Override
    public String value(String k) {
        if (StringUtils.isNotEmpty(k)) {
            FacilityConfigCode[] values = FacilityConfigCode.values();
            for (FacilityConfigCode o : values) {
                if (o.getT().equals(getT()) && o.getK().equals(k)) {
                    return o.getV();
                }
            }
        }
        return k;
    }
}
